# Ollama Llava 13B 快速测试脚本
Write-Host "🦙 Ollama Llava 13B 快速测试" -ForegroundColor Cyan
Write-Host ""

# 检查Ollama服务
Write-Host "1️⃣ 检查Ollama服务状态..." -ForegroundColor Yellow
try {
    $response = Invoke-RestMethod -Uri "http://localhost:11434/api/tags" -Method Get
    Write-Host "✅ Ollama服务正常运行" -ForegroundColor Green
    
    # 检查模型
    $hasLlava = $response.models | Where-Object { $_.name -like "*llava:13b*" }
    if ($hasLlava) {
        Write-Host "✅ llava:13b 模型已就绪" -ForegroundColor Green
        Write-Host "📊 模型大小: $([math]::Round($hasLlava.size / 1GB, 1)) GB" -ForegroundColor Cyan
    } else {
        Write-Host "❌ 未找到llava:13b模型" -ForegroundColor Red
        return
    }
} catch {
    Write-Host "❌ Ollama服务未运行，请先启动: ollama serve" -ForegroundColor Red
    return
}

Write-Host ""

# 测试文本对话
Write-Host "2️⃣ 测试文本对话..." -ForegroundColor Yellow
try {
    $body = @{
        model = "llava:13b"
        messages = @(
            @{
                role = "user"
                content = "你好，请用中文简单介绍你的功能。"
            }
        )
        stream = $false
    } | ConvertTo-Json -Depth 5

    $chatResponse = Invoke-RestMethod -Uri "http://localhost:11434/api/chat" -Method Post -Body $body -ContentType "application/json"
    
    Write-Host "✅ 文本对话测试成功!" -ForegroundColor Green
    Write-Host "🤖 AI回复: " -ForegroundColor Cyan -NoNewline
    Write-Host $chatResponse.message.content.Substring(0, [Math]::Min(100, $chatResponse.message.content.Length)) + "..." -ForegroundColor White
} catch {
    Write-Host "❌ 文本对话测试失败: $($_.Exception.Message)" -ForegroundColor Red
}

Write-Host ""

# 系统信息
Write-Host "📊 系统信息:" -ForegroundColor Yellow
Write-Host "🖥️ Ollama地址: http://localhost:11434" -ForegroundColor Gray
Write-Host "🤖 模型名称: llava:13b" -ForegroundColor Gray
Write-Host "🎯 集成状态: 已完成" -ForegroundColor Green

Write-Host ""
Write-Host "🚀 下一步操作:" -ForegroundColor Yellow
Write-Host "  1. 启动后端服务: cd server && npm run dev" -ForegroundColor Gray
Write-Host "  2. 启动前端服务: cd h5 && npm run dev" -ForegroundColor Gray  
Write-Host "  3. 访问演示页面: http://localhost:3000/ollama-demo" -ForegroundColor Gray
Write-Host "  4. 点击右下角 'Llava3 AI' 按钮开始使用" -ForegroundColor Gray

Write-Host ""
Write-Host "🎉 您的Ollama Llava 13B已经成功集成到医疗数字孪生系统中！" -ForegroundColor Green